
//锁
let _lock = (function () {

    "use strict";

    //私锁
    let __mutex = false;

    //加锁
    let _lock = function () {
        __mutex = true;
    };

    //解锁
    let _unlock = function () {
        __mutex = false;
    };

    //实例
    let __instance = null;
    //自动锁类
    let Class = function (func) {};

    //实现单例
    let GetInstance = function () {
        if (__instance == null)
        {
            __instance = new Class();
        }
        return __instance;
    };

    //加锁执行
    Class.prototype._exec = function (func) {

        if (__mutex)
            return ;

        if(typeof func !== "function")
        {
            _exception._not_function("func", true);
            return ;
        }

        _lock();
        try {

            delete arguments[0];
            let args = _object._to_array(arguments);
            func.apply(this, args);

        } catch (e) {

            _exception._console(e);
        }
        _unlock();
    }

    //返回
    return GetInstance();

})();


//导出
export default _lock;
